															   /****** Object:  Stored Procedure [dbo].spPhieuNhapGet Script Date: 6/12/2012 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[spPhieuGiaoHangGetForPrinting]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spPhieuGiaoHangGetForPrinting]
GO

/******************************************************************************
**		Change History
*******************************************************************************
**		Date:		Author:					Description:
**		--------	--------				-----------------------------------
**		24/06/2012	SongTM					Innit created
*******************************************************************************/

CREATE PROCEDURE [dbo].[spPhieuGiaoHangGetForPrinting]
(
	@SoPG nvarchar(14)
)
WITH ENCRYPTION
AS

SET NOCOUNT ON

SELECT 
	*
FROM 
	[tbl_PhieuGiaoHang] INNER JOIN [tbl_PhieuXuat] ON [tbl_PhieuGiaoHang].SoPX=[tbl_PhieuXuat].SoPX
	Inner join tbl_ChiTietPhieuXuat ON [tbl_ChiTietPhieuXuat].SoPX= [tbl_PhieuXuat].SoPX
	INNER JOIN tbl_LuuKho ON [tbl_ChiTietPhieuXuat].MaLuuKho = [tbl_LuuKho].MaLuuKho
	INNER JOIN tbl_KhachHang ON [tbl_KhachHang].MaKH = [tbl_PhieuGiaoHang].MaKH
	INNER JOIN tbl_SanPham ON [tbl_LuuKho].MaThuoc = tbl_SanPham.Mathuoc
	INNER JOIN tbl_DonViTinh ON [tbl_DonViTinh].MaDonVi = [tbl_SanPham].MaDonVi
WHERE
	[tbl_PhieuGiaoHang].[SoPG] = @SoPG
	
Select * from tbl_congty
GO
--GRANT EXECUTE ON [dbo].[spPhieuNhapGet] TO [sa]   PG001/0612/NP
--GO
